import './App.css';
import { useDispatch, useSelector } from 'react-redux';
import { decrement,inscrement,addToNum } from './store/modules/coutnterStore';
import { fetchChanelList } from './store/modules/channelStore';
import { useEffect } from 'react';


// 1.需求传植
// 传过去的值会变成payload


function App() {
  // 使用
  const {count} =useSelector(state=>state.counter)
  // const {setchanelList} =useSelector(state=>state.channel)
  const dispath =useDispatch()
  // 请求数据
  useEffect(()=>{
    dispath(fetchChanelList())
  },[dispath])
  return (
    <div className="App">
      {count}
      <button onClick={()=>{
        dispath(inscrement())
      }}>点击增加</button>
      <button onClick={()=>{
        dispath(decrement())
      }}>点击减少</button>
      <button onClick={()=>{dispath(addToNum(10))}}>点击减少10</button>
      {/* <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload.
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header> */}
    </div>
  );
}

export default App;
